﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.IBLL;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class PS_RoyalItemRepays : System.Web.UI.UserControl
    {
        private SsMng ssMng = new SsMng();
        private IRoyalItemRepayBLL reBLL = new RoyalItemRepayBLL();
        private object _dataItem = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (DataItem != null)
            {
                if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
                {
                    //lblRepaySeq.Text = DataBinder.Eval(DataItem, "Sequence").ToString();
                    //txtRefNo.Text = DataBinder.Eval(DataItem, "RefNo").ToString();
                    //txtRepayDescr.Text = DataBinder.Eval(DataItem, "Description").ToString();
                    txtStartDate.SetValue(DataBinder.Eval(DataItem, "StartDate", "{0:dd/MM/yyyy}").ToString());
                    txtEndDate.SetValue(DataBinder.Eval(DataItem, "EndDate", "{0:dd/MM/yyyy}").ToString());
                    //txtRemarks.Text = DataBinder.Eval(DataItem, "Remarks").ToString();
                }
            }
        }

        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }

        protected void btnAddnew_Click(object sender, EventArgs e)
        {
            reBLL.Insert(txtRefNo.Text.Trim()
                , txtRepayDescr.Text.Trim()
                , txtStartDate.GetStringValue()
                , txtEndDate.GetStringValue()
                , txtRemarks.Text.Trim()
                , ssMng.EmpSeqI);

        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            reBLL.Update(Int32.Parse(lblRepaySeq.Text.Trim())
                , txtRefNo.Text.Trim()
                , txtRepayDescr.Text.Trim()
                , txtStartDate.GetStringValue()
                , txtEndDate.GetStringValue()
                , txtRemarks.Text.Trim()
                , ssMng.EmpSeqI);
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {

        }
    }
}